import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JPanel;

public class EmployeeForm extends JPanel{
	private static final long serialVersionUID = 1L;
	JLayeredPane eMainLay;
	//private static mainEmployee eMain = new mainEmployee(); //unused: mainEmployee is not needed
	private static EmpProfileForm eProf;
	private static EmpAttendForm eAttend;
	private static EmpPayrollForm ePayroll;
	private static welcomP contenPan = new welcomP();
	private static JButton home;
	
	//////////////integration of buttons and images from mainEmployee//////////////////////////
	JButton logOut, proFile, attenD, payRoll;
	
	private  ImageIcon hOme = new ImageIcon(this.getClass().getResource("images/emp/home.png"));
	private  ImageIcon lOut = new ImageIcon(this.getClass().getResource("images/logout.png"));
	private  ImageIcon pRo = new ImageIcon(this.getClass().getResource("images/emp/profile.png"));
	private  ImageIcon aTt = new ImageIcon(this.getClass().getResource("images/emp/attendance.png"));
	private  ImageIcon pAy = new ImageIcon(this.getClass().getResource("images/emp/payroll.png"));
	///////////////////////////////////////////////////////////////////////////////////////////
	
	public EmployeeForm(){
		eProf = new EmpProfileForm();
		eAttend = new EmpAttendForm();
		ePayroll = new EmpPayrollForm();
		home = new JButton(hOme);
		home.setBounds(358,44,65,31);
		home.setContentAreaFilled(false);
		home.setVisible(true);
		
		
	//////integration of button layouts///////
		logOut = new JButton(lOut);
		logOut.setBounds(735,5,63,27);
		logOut.setContentAreaFilled(false);
		logOut.setVisible(true);
		
		proFile = new JButton(pRo);
		proFile.setBounds(425,44,102,31);
		proFile.setVisible(true);
		
		attenD = new JButton(aTt);
		attenD.setBounds(532,44,102,31);
		attenD.setVisible(true);
		
		payRoll = new JButton(pAy);
		payRoll.setBounds(639,44,102,31);
		payRoll.setVisible(true);
	///////////////////////////////////////////
		
		eMainLay = new JLayeredPane();
		eMainLay.setOpaque(false);
		eMainLay.setSize(806,628);
	//	eMainLay.add(eMain);   //unused: removal of mainEmployee fields
		eMainLay.add(contenPan);
		eMainLay.add(eProf);
		eMainLay.add(eAttend);
		eMainLay.add(ePayroll);
		eMainLay.add(home);
		
	///integration of object addition to pane///
		eMainLay.add(proFile);
		eMainLay.add(attenD);
		eMainLay.add(payRoll);
		eMainLay.add(logOut);
	////////////////////////////////////////////
		
		contenPan.setBounds(0, 2, 617, 437);
		
		eMainLay.setVisible(true);
		
		
		add(eMainLay);
		setLayout(null);
		setOpaque(false);
		setSize(806,628);
		setVisible(true);
		goToPage(0);
		
		home.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				EmployeeForm.goToPage(0);
		}
		});
		
	////////////////integration of action listeners of the buttons/////////////////
		proFile.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				EmployeeForm.getProfile().profileUpdate();
				EmployeeForm.goToPage(1);
		}
		});
		
		attenD.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				EmployeeForm.getAttend().getPane().attendUpdate();
				EmployeeForm.goToPage(2);
		}
		});
		
		payRoll.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				EmployeeForm.getPayroll().getPane().payrollUpdate();
				EmployeeForm.goToPage(3);
		}
		});
		
		logOut.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				setVisible(false);
				EmployeeForm.goToPage(0);
				AdminForm.goToPage(0);
				MainPanel.goToPage(0);
		}
		});
	//////////////////////////////////////////////////////////////
		
	}
	
	public static void goToPage(int x){
		contenPan.setVisible(false);
		home.setVisible(false);
		eProf.setVisible(false);
		eAttend.setVisible(false);
		ePayroll.setVisible(false);
		
		switch(x){
		case 0: contenPan.setVisible(true); break;
		case 1: home.setVisible(true); eProf.setVisible(true); break;
		case 2: home.setVisible(true); eAttend.setVisible(true); break;
		case 3: home.setVisible(true); ePayroll.setVisible(true); break;
		}
	}
	
	public static EmpProfileForm getProfile(){
		return eProf;
	}
	public static EmpAttendForm getAttend(){
		return eAttend;
	}
	public static EmpPayrollForm getPayroll(){
		return ePayroll;
	}
}

/*unused class
class mainEmployee extends JPanel{
private static final long serialVersionUID = 1L;
	
	
	public mainEmployee(){
		
		
		
		setLayout(null);
		setOpaque(false);
		setSize(806,628);
		setVisible(true);
	
		
	}
}
*/

class welcomP extends JPanel {
	private static final long serialVersionUID = 1L;
	JLabel contentM, greet;
	private  ImageIcon welC = new ImageIcon(this.getClass().getResource("images/header/welcome.png"));
	SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM d, yyyy");
	Calendar now = Calendar.getInstance();
	String welcomeStr = "<html><h3>Hello! Today is " + dateFormat.format(now.getTime()) + 
						". </h3> <hr width=550px /> <blockquote>What would you like to do today? </blockquote> </html>";

	welcomP(){
	
		greet = new JLabel(welC);
		greet.setBounds(135, 35, 265, 40);
		greet.setVisible(true);
		
		contentM = new JLabel(welcomeStr);
		contentM.setBounds(140, 80, 550, 100);
		contentM.setVisible(true);
		contentM.setForeground(Color.BLACK);
		
		setLayout(null);
		setOpaque(false);
		setVisible(true);
		add(contentM);
		add(greet);
	}
}
